cc.Class({
	extends: cc.Component,

	properties: {
		usernameEditBox: cc.EditBox,
		passwordEditBox: cc.EditBox,
	},

	// onLoad () {},

	start() {
	},
	onBtnRegisterClick() {
		let data = {
			accountID: this.usernameEditBox.string,
			password: this.passwordEditBox.string,
		};
		cc.vv.CMM.request_register(data, (err, info) => {
			if (err) {
				cc.log(err);
			} else {
				// cc.vv.playerInfo.accountID = info.accountID;
				// cc.director.loadScene("game");
				// 调用登录
				this.onBtnLoginClick();
			}
		});
	},
	onBtnLoginClick() {
		let data = {
			accountID: this.usernameEditBox.string,
			password: this.passwordEditBox.string,
		};
		cc.vv.CMM.request_login(data, (err, info) => {
			if (err) {
				cc.log(err);
			} else {
				cc.vv.PlayerInfo = info;
				cc.director.loadScene("game");
			}
		});
	},

	// update (dt) {},
});
